package com.oracle.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.oracle.Service.impl.UserService;
import com.oracle.dao.impl.UserDao;
import com.oracle.pojo.User;
import com.oracle.pojo.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public Page<User> showUsers(Integer currentPage, Integer pageSize, UserVo userVo) {
        Page<User> pages = PageHelper.startPage(currentPage, pageSize);
        userDao.showUsers(userVo);
        return pages;
    }

    @Override
    public User SelectUserByUserName(User user) {
        return userDao.SelectUserByUserName(user);
    }

    @Override
    public String addNewUser(User user) {
        String result = userDao.addNewUser(user);
        if(result.equals("NO")){
            return "NO";
        }
        return "YES";
    }

    @Override
    public User findOneByUid(Integer uid) {
        return userDao.findOneByUid(uid);
    }

    @Override
    public Integer updateUserInfo(User user) {
        return userDao.updateUserInfo(user);
    }
}
